package 数组.easy;

/**
 * @author Lw中
 * @date 2020/8/12 10:03
 */
public class YiSanLingSi {

    public static int[] sumZero(int n) {
        int[] arr = new int[n];
        // 当n为奇数时，中间值为零，数组只有元素值关于0对称
        // 当n为偶数时，数组左右元素值对称
        for (int i = 0; i < n / 2; i++) {
            arr[i] = i + 1;
            arr[n-i-1] = -arr[i];
        }
        return arr;
    }

    public static void main(String[] args) {
        int[] ints = sumZero(5);
        for (int i = 0; i < ints.length; i++) {
            System.out.println(ints[i]);
        }
    }

}
